<?php
session_start();
require_once( 'configs/config.php' );
require_once( 'lib/db.php' );

if( (isset( $_SESSION[ 'UID' ] ) && $_GET[ 'id' ] == $_SESSION[ 'UID' ] ) || $_SESSION[ 'Level' ] == $config[ 'Admin' ] )
{
	$smarty->assign('logged_in', 'true');
	$smarty->assign('admin', 'true');
	$smarty->assign('self', 'true');
}
else
{
	header( 'Location: login.php' );
	exit;
}

if( !$_GET['id'] )
{
	header('Location: ' . $_SERVER['HTTP_REFERER']);
}
else
{
	$id = $_GET['id'];
}

// Get list of tables from current database..
$image = $db->get_var('SELECT Photograph FROM users WHERE UserUID = ' . $id);

header('Content-Type: image/jpeg');
echo $image;
?>